/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package controller.admin;

import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import javax.ejb.EJB;
import model.*;
import entities.*;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 *
 * @author xuanthuy
 */
@Named(value = "usersManagedBean")
@SessionScoped
public class UsersManagedBean implements Serializable {

    @EJB
    private UsersFacade usersFacade;

    private TimeZone tm;
    private Users user = new Users();
    private String email;

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Users getUser() {
        return user;
    }

    public void setUser(Users user) {
        this.user = user;
    }

    public TimeZone getTm() {
        tm = TimeZone.getDefault();
        return tm;
    }

    public UsersManagedBean() {
    }

    public List<Users> findAll() {
        return this.usersFacade.findAll();
    }

    public String edit(Users user) {
        this.user = user;
        return "usersAdEdit";
    }

    public String xulycapnhat() {
        this.usersFacade.edit(this.user);
        return "usersAd?faces-redirect=true";
    }

    public void xoa(Users user) {
        this.usersFacade.remove(user);
    }
    
    public String maxDate() {
        Date thoiGian = new Date();
        SimpleDateFormat dinhDangThoiGian = new SimpleDateFormat("dd/MM/yyyy");
        String showTime = dinhDangThoiGian.format(thoiGian.getTime());
        System.out.println("" + showTime);
        return showTime;
    }

}
